// PatternMiningDriver.java
package com.taxi.analysis.pattern;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class PatternMiningDriver {

    public static void main(String[] args) throws Exception {

        if (args.length != 2) {
            System.err.println("使用方法: PatternMiningDriver <输入路径> <输出路径>");
            System.exit(-1);
        }

        Configuration conf = new Configuration();
        conf.set("mapreduce.job.name", "NYC_Taxi_Pattern_Mining_Deduplication");
        conf.setInt("mapreduce.task.timeout", 3600000);
        conf.setInt("mapreduce.map.memory.mb", 2048);
        conf.setInt("mapreduce.reduce.memory.mb", 4096);

        Job job = Job.getInstance(conf, "出行模式挖掘_去重技术");

        job.setJarByClass(PatternMiningDriver.class);
        job.setMapperClass(PatternMiningMapper.class);
        job.setReducerClass(PatternMiningReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        job.setNumReduceTasks(8);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        System.out.println("=== 启动出行模式挖掘任务 ===");
        System.out.println("使用技术: 去重技术");
        System.out.println("分析目标: 出行模式挖掘与去重优化");

        boolean success = job.waitForCompletion(true);

        if (success) {
            System.out.println("=== 出行模式挖掘任务完成 ===");
            System.out.println("去重结果包含:");
            System.out.println("- 精确去重模式分析");
            System.out.println("- 模糊去重模式聚合");
            System.out.println("- 时间窗口去重分析");
            System.out.println("- 用户模式去重挖掘");
        } else {
            System.err.println("=== 出行模式挖掘任务失败 ===");
        }

        System.exit(success ? 0 : 1);
    }
}
